package com.wangjiacai.hql.condition.where;

import com.wangjiacai.hql.condition.Condition;

import java.lang.annotation.*;

@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Condition(condition = NotNull.NotNullCondition.class,column =  NotNull.NotNullCondition.class)
public @interface NotNull {

    String column() default "";

    class NotNullCondition implements Condition.Where, Condition.Column<NotNull> {
        @Override
        public String where(Annotation notNull, String property, String column, Object obj,Object value) {
            return column+" is not null";
        }

        @Override
        public String column(NotNull notNull, String property) {
            return notNull.column().equals("")?property:notNull.column();
        }
    }
}
